package ru.papergames.battleserver.model.battle.npc;

import ru.papergames.battleserver.model.battle.BattlePlayer;

/**
 * Date: 11.05.12 21:08
 * @author Alexander Troshanin
 */
public class NpcsManager {
    private static NpcsManager instance = new NpcsManager();

    private NpcsControllerThread [] controllers;

    private NpcsManager() {
        controllers = new NpcsControllerThread[1];
        for (int i=0; i<controllers.length; i++) {
            controllers[i] = new NpcsControllerThread();
        }
    }

    public static NpcsManager getInstance() {
        return instance;
    }

    public boolean addNpcToProcess(BattlePlayer npcPlayer) {
        for (NpcsControllerThread controller : controllers) {
            if (controller.addNpcToProcess(npcPlayer)) {
                return true;
            }
        }
        return false;
    }

    public void start() {
        for (NpcsControllerThread controller : controllers) {
            controller.start();
        }
    }

    public void shutDown() {
        for (NpcsControllerThread controller : controllers) {
            controller.shutDown();
        }
    }
}
